package UDP;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;

public class UDPDictServer extends UDPEchoServer{

    private HashMap<String, String> dict = new HashMap<>();


    public UDPDictServer(int port) throws SocketException {
        super(port);
        dict.put("小猫", "cat");
        dict.put("小狗", "dog");
        dict.put("小羊", "sheep");
    }

    public String process(String request) {
        return dict.getOrDefault(request, "未找到该词条");
    }

    public static void main(String[] args) throws IOException {
        UDPDictServer udpDictServer = new UDPDictServer(9090);
        udpDictServer.start();
    }
}
